<template>
  <div class="login">
    <ul class="theme">
      <li class="theme1 cursor"
          @click="setTheme('theme1')"></li>
      <li class="theme2 cursor"
          @click="setTheme('theme2')"></li>
    </ul>
    <div class="login-box-center">
      <div class="form-box">
        <el-form :model="ruleForm"
                 status-icon
                 :rules="rules"
                 ref="ruleForm"
                 label-width="100px"
                 class="demo-ruleForm">
          <el-form-item label="密码"
                        prop="pass">
            <el-input type="password"
                      v-model="ruleForm.pass"
                      autocomplete="off"></el-input>
          </el-form-item>
          <el-form-item label="确认密码"
                        prop="checkPass">
            <el-input type="password"
                      v-model="ruleForm.checkPass"
                      autocomplete="off"></el-input>
          </el-form-item>

          <el-form-item>
            <el-button type="primary"
                       @click="submitForm('ruleForm')">确定</el-button>
            <el-button @click="resetForm('ruleForm')">重置</el-button>
          </el-form-item>
        </el-form>
      </div>
    </div>
  </div>
</template>
<script>
import {login} from "api/api.js";
export default {
  name: "login",
  data () {
    let validatePass = (rule, value, callback) => {
      if (value === "") {
        callback(new Error("请输入密码"));
      } else {
        if (this.ruleForm.checkPass !== "") {
          this.$refs.ruleForm.validateField("checkPass");
        }
        callback();
      }
    };
    return {
      a: "a",
      ruleForm: {
        pass: "",
        checkPass: ""
      },
      rules: {
        pass: [{ validator: validatePass, trigger: "blur" }],
        checkPass: [{ validator: validatePass, trigger: "blur" }]
      }
    };
  },
  created () {
    // login.then(res => {
    //   let a = "a";
    // });
  },
  methods: {
    get () {
      return "a";
    },
    setTheme (theme) {
      localStorage.setItem("theme", theme);
      window.document.documentElement.setAttribute("data-theme", theme);
    },
    submitForm () {

      this.$router.push({ name: "index" });
    }
  }
};
</script>

<style lang="scss" scoped>
@import "../../styles/base.scss";
.login {
  position: relative;
  width: 100%;
  height: 100%;

  .theme {
    position: absolute;
    top: 16px;
    right: 15px;
    li {
      display: inline-block;
      width: 30px;
      height: 30px;
      margin: 0 6px;
      border: 2px solid #fff;
      border-radius: 50%;
      &:hover {
        // position: absolute;
        // width: 31px;
        // height: 31px;
      }
    }
    .theme1 {
      background-color: $theme1;
    }
    .theme2 {
      background-color: $theme2;
    }
  }
  .login-box-center {
    width: 100%;
    height: 100%;
    @include all_center();
    .form-box {
      @include all_center();
      background-color: #fff;
      padding: 25px;
      border-radius: 8px;
    }
  }
}
</style>
